package com.huawei.crm.sample.application.order.converter;

import com.huawei.crm.sample.application.order.dto.OrderDTO;
import com.huawei.crm.sample.domain.order.model.aggragate.Order;
import com.huawei.crm.sample.domain.order.model.entity.OrderItem;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;

@Mapper(componentModel = "spring")
public interface OrderDTOConverter {

    @Mapping(target = "items", source = "items")
    OrderDTO toDTO(Order order);
    @Mapping(target = "items", source = "items")
    Order toDomain(OrderDTO dto);

    OrderDTO.OrderItemDTO toItemDTO(OrderItem item);
    OrderItem toItem(OrderDTO.OrderItemDTO dto);

    List<OrderDTO.OrderItemDTO> toItemDTOList(List<OrderItem> items);
    List<OrderItem> toItemList(List<OrderDTO.OrderItemDTO> dtos);
} 